#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

class Solution
{
public:
    int smallestDivisor(vector<int> &nums, int threshold)
    {
        int left = 1, right = 1000'000;
        while (left <= right)
        {
            int mid = (left + right) / 2;
            int sum = accumulate(nums.begin(), nums.end(), 0, [mid](int acc, int num)
                                 { return acc + (num - 1) / mid + 1; });
            if (sum > threshold)
            {
                left = mid + 1;
            }
            else
            {
                right = mid - 1;
            }
        }
        return left;
    }
};

int main()
{
    cout << "Code1283" << endl;
    Solution s;
    vector<int> nums = {44, 22, 33, 11, 1};
    cout << s.smallestDivisor(nums, 5) << endl;
    return 0;
}